import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;


/**
 * @author ckf
 * @create 2018 05 25 18:49
 * @desc
 **/

public class homework3 {
    public static void main(String[] args) throws IOException {

        File file = new File("D:\\zz.txt");
        File file2 = null;
        if (!file.exists()) {
            System.out.println("文件不存在");

        } else {
            file2 = new File("D:\\copy_zz.txt");
            file2.createNewFile();
            System.out.println("创建完毕");
        }
        FileInputStream fis = new FileInputStream(file);// 创建输入流
        DataInputStream dis = new DataInputStream(fis);// 二进制写文件

        FileOutputStream fos = new FileOutputStream(file2);
        DataOutputStream dos = new DataOutputStream(fos);
        try {
            int tem;
            while ((tem = dis.read()) != -1) {
                dos.write(tem);
                System.out.print((char) tem);
            }
            System.out.println("复制完毕");
        } catch (IOException e) {
            e.getMessage();
        } finally {
            dis.close();
            fis.close();
            fos.close();
            dos.close();
        }

    }

}
